package com.shiwenping.reply.recycle;

import android.support.v4.view.GestureDetectorCompat;
import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;
import android.view.View;

/**
 *
 * @author haichecker
 * @date 17-11-8
 */

public abstract class OnItemClickListener implements RecyclerView.OnItemTouchListener{
    private GestureDetectorCompat mGestureDetectorCompat;

    public OnItemClickListener() {

    }

    @Override
    public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

    }

    public abstract void onClick(RecyclerView.ViewHolder viewHolder, int position);

    @Override
    public void onTouchEvent(RecyclerView rv, MotionEvent e) {
        if (mGestureDetectorCompat == null) {
            mGestureDetectorCompat = new GestureDetectorCompat(rv.getContext(),
                    new MyGestureListener(this,rv));
        }
        mGestureDetectorCompat.onTouchEvent(e);
    }

    @Override
    public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
        if (mGestureDetectorCompat == null) {
            mGestureDetectorCompat = new GestureDetectorCompat(rv.getContext(),
                    new MyGestureListener(this,rv));
        }
        mGestureDetectorCompat.onTouchEvent(e);
        return false;
    }
}
